import request from './request'

const http = {
    // 首页==========================================================>
    /**
     * @method
     * @description 获取轮播图数据
     */
    getSwiperData: () => request('home/swiperdata'),
    /**
     * @method
     * @description 获取导航栏数据
     */
    getCatItems: () => request('home/catitems'),
    /**
     * @method
     * @description 获取楼层数据
     */
    getFloorList: () => request('home/floordata'),



    // 分类==========================================================>
    /**
     * @method
     * @description 获取商品分类数据
     */
    getCategories: () => request('categories'),



    // 商品==========================================================>
    /**
     * @method
     * @param {Number} id 商品id
     * @description 获取商品详情数据
     */
    getDetail: (goods_id) => request('goods/detail', {
        data: {
            goods_id
        }
    }),
    /**
     * @method
     * @description 获取商品列表数据
     * @param {Object} model 分页搜索参数
     */
    getGoodList: (model) => request('goods/search', {
        data: {
            ...model
        }
    }),


    // 搜索==========================================================>
    /**
     * @method
     * @description 商品搜索
     * @param {Object} model 搜索关键字
     * @returns 
     */
    goSearch: (model) => request('goods/qsearch', {
        data: {
            ...model
        }
    }),


    // 用户==========================================================>
    /**
     * @method
     * @description 获取token
     * @param {Object} model 用户登录参数
     */
    getWxLogin: (model) => request('users/wxlogin', {
        data: {
            ...model
        },
        method: 'POST'
    }),


    // 支付==========================================================>
    /**
     * @method
     * @description 获取支付参数
     * @param {String} order_number 
     */
    pay: (order_number) => request('my/orders/req_unifiedorder', {
        data: {
            order_number
        },
        method: 'POST'
    }),


    // 订单==========================================================>
    /**
     * @method
     * @description 创建订单
     * @param {Object} model 商品参数
     */
    addOrders: (model) => request('my/orders/create', {
        data: {
            ...model
        },
        method: 'POST'
    }),

    /**
     * @method
     * @description 查看订单支付状态
     * @param {String} model 订单编号
     */
    chkOrder: (order_number) => request('my/orders/chkOrder', {
        data: {
            order_number
        },
        method: 'POST'
    }),


    /**
     * @method
     * @description 历史订单查询
     * @param {Number} model 订单状态
     */
    allOrders: (type) => request('my/orders/all', {
        data: {
            type
        }
    }),


}


export default http